/* author: Mariana Horita
   mariana.horita@gmail.com
   file: A4E2.cs*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Resolucao
{
    public partial class A4E2 : Form
    {
        private Button[,] btTela;
        private int nBt = 10;
        private int larg = 50;
        private int alt = 25;

        public A4E2()
        {
            InitializeComponent();
        }

        private void A4E2_Load(object sender, EventArgs e)
        {
            btTela = new Button[nBt, nBt];

            for (int i = 0; i < nBt; i++)
            {
                for (int j = 0; j < nBt; j++)
                {
                    btTela[i, j] = new Button();
                    btTela[i, j].Size = new Size(larg, alt);
                    btTela[i, j].Location = new Point(i * larg, j * alt);
                    btTela[i, j].Text = "0";
                    btTela[i, j].MouseEnter += new EventHandler(A4E2_MouseEnter);
                    btTela[i, j].MouseLeave += new EventHandler(A4E2_MouseLeave);
                    btTela[i, j].Click += new EventHandler(A4E2_Click);
                    
                    this.Controls.Add(btTela[i, j]);
                }
            }
        }

        void A4E2_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            bt.Text = (Convert.ToInt32(bt.Text) + 1).ToString();
        }

        void A4E2_MouseLeave(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            
            int cor = Convert.ToInt32(bt.Text);

            bt.BackColor = Color.FromArgb(cor * 2 % 255, cor * 5 % 255, cor * 10 % 255);
        }

        void A4E2_MouseEnter(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            bt.BackColor = Color.Red;
        }

        

       
    }
}
